<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    

    <script>

        let quickSrot = function(nums){
            quick(nums,0,nums.length-1);
        }
        let quick = function(nums,start,end){
            if(start >= end) {
                return;
            }
            let pivot = partition(nums,start,end);
            quick(nums,start,pivot-1);
            quick(nums,pivot+1,end);
        }
        // 找基准
        let partition = function(nums,start,end){
            let temp = nums[start];
            while(start < end){
                
                while(start < end && nums[end] >= temp){
                    end--;
                }
                // 找到 < temp的值了
                nums[start] = nums[end];
                while(start < end && nums[start] <= temp){
                    start++;
                }
                // 找到 > temp的值了
                nums[end] = nums[start];
            }
            nums[start] = temp;
            return start;
        }


        let nums = [12,3,65,7,99,14,66];
        quickSrot(nums);
        console.log(nums);
    </script>
</body>
</html>